package com.homework;

/**
 * @author :  DongZheng Wang
 * @PROJECT_NAME: java泛型
 * @date :  2022-10-25 16:46
 **/
public class Five {
    public static void main(String[] args) {
        A<Integer> objectA = new A<>();
       objectA.setA(22);
        System.out.println(objectA);
        fun(objectA);


        A<String> object = new A<>();
        object.setA("22");
        System.out.println(object);
        fun1(object);

    }
    public static void fun(A<? extends Number> a){//改泛型的上线他本身或者他的子类
   a.fun();
    }
    public static void fun1(A<? super String> a){//改泛型的下线指的他或者它上面的
        a.fun();
    }
}
class A<T>{
private T a;

    public T getA() {
        return a;
    }

    public void setA(T a) {
        this.a = a;
    }

    public void fun(){
        System.out.println("a====="+a);
    }

    @Override
    public String toString() {
        return "A{" +
                "a=" + a +
                '}';
    }
}